package com.weijian.controller;

import com.weijian.common.result.ApiResponse;
import com.weijian.dto.ai.ConversationRequestDTO;
import com.weijian.dto.ai.ConversationResponseDTO;
import com.weijian.service.ConversationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * AI数据分析对话接口
 */
@Tag(name = "AI数据分析对话", description = "AI数据分析对话接口")
@RestController
@RequestMapping("/api/conversation")
public class ConversationController {

    @Autowired
    private ConversationService conversationService;

    /**
     * 发送消息并获取AI数据分析结果
     *
     * @param userId  用户ID
     * @param request 对话请求
     * @return AI数据分析结果
     */
    @Operation(summary = "发送消息并获取AI数据分析结果")
    @PostMapping("/send/{userId}")
    public ApiResponse<ConversationResponseDTO> sendMessage(
            @Parameter(description = "用户ID") @PathVariable Long userId,
            @Parameter(description = "对话请求参数") @Valid @RequestBody ConversationRequestDTO request) {
        ConversationResponseDTO response = conversationService.sendMessage(userId, request);
        return ApiResponse.success(response);
    }
}